MapDirections PRO
MapDirections plans routes between two endpoints using MapKit. Two entry points:
MapDirections.calculate(options)— full route(s) with turn-by-turn steps and a ready-to-render polyline.MapDirections.calculateETA(options)— travel time / distance / arrival window only. Cheaper and faster thancalculatewhen you don't need the geometry.
Both APIs are network-backed by Apple's directions servers and require no iOS system permissions. The result is plain data — no opaque handles to dispose.
Pair with the views layer: route.coordinates is shaped exactly for
<MapPolyline coordinates={route.coordinates}> from the <Map> view.
calculate — plan a route
Options
DirectionsResponse
DirectionsRoute
Rendering with <MapPolyline>
calculateETA — time / distance only
Use this when you only need the headline numbers — it skips downloading the
full route geometry, so it's noticeably faster than calculate.
Notes & limitations
- Transit (
transportType: "transit") is supported in a limited set of regions. Outside those, the request rejects withdirectionsNotFound. For broad coverage prefer"automobile"or"walking". - Alternates typically only return multiple routes for driving on roads with realistic alternatives — walking usually returns a single route.
- No cancel handle: a new
calculatecall doesn't cancel an in-flight one. Responses arrive in whatever order Apple's servers return them, so if you fire requests rapidly (e.g. while the user is moving sliders) implement your own "latest-wins" guard. departureDateandarrivalDateare mutually exclusive: if both are provided,departureDatewins;arrivalDateis ignored.
